<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
	
	<title>发布信息</title>
	<link rel="stylesheet" href="css/reset.css" />
	<link rel="stylesheet" href="css/public.css" />
	<link rel="stylesheet" href="css/content.css" />
	<script src="js/jquery-2.1.1.js"></script>
	<script src="js/json2.js"></script>
	
	<script type="text/javascript">
	$(function(){
		
		//动态加载商品类型
		$.ajax({
   			type: "get",
   			url: "${pageContext.request.contextPath }/GetTypeForFaBu",
  			success:function(response,status,xhr){
    			var jsonStr=xhr.responseText;
				var types=eval('('+jsonStr+')');
				for(var i=0;i<types.length;i++){
					$(".form-select").append("<option value='"+types[i].typeId+"'>"+types[i].typeName+"</option>");
				}
   			}
		}); 
		
		
	});
	
	//检查商品输入信息	
	 function checkInfo(form){
	 	
	 	//获取select选中的文本
	 	//var classifyId=$(".form-select").find("option:selected").text();
	 	
	 	var classifyId=$(".form-select").val();
	 	
		 if(classifyId==""){
			 alert("分类不能为空！");
			 return false;
		}
		
		var proName=$(":input[name='proName']").val();
		if(proName==""){
			alert("商品名称不能为空！");
			return false;
		}
		
		var proPrice=$(":input[name='proPrice']").val();
		if(proPrice==""){
			alert("商品价格不能为空！");
			return false;
		}
		var re = /^[0-9]+.?[0-9]*$/; 
		if(!re.test(proPrice)){
			alert("商品价格格式不正确");
			return false;
		}
	
		var proHassum=$(":input[name='proHassum']").val();
		if(proHassum==""){
			alert("剩余量不能为空！");
			return false;
		}
		
		if(!re.test(proHassum)){
			alert("剩余量不能为空");
			return false;
		}
		
		return true;
		
	}
	
	</script>
</head>
<body>
  <input type="hidden" name="flag" value="${flag }">
  <jsp:include page="top.jsp" flush="true"/>
	<div class="container">
		<div class="public-nav">您当前的位置：><a href="">发布信息</a></div>
		<div class="public-content" style="margin-top: 0">
			<div class="public-content-cont">
			<div style="margin:0 auto;width:50%">
			<form action="${pageContext.request.contextPath}/FaBuGoods" method="post" enctype="multipart/form-data" onsubmit="return checkInfo(this);">
				<input type="hidden" name="uid" value="${user_login.userId }">
				<input type="hidden" name="uname" value="${user_login.userName }">
				
				<div class="form-group">
					<label for="">请选择分类</label>
					<select name="classifyId" class="form-select" style="height: 30px;" id="classify">
						<option></option>
					</select>
				</div>
				
				<div class="form-group">
					<label for="">商品名称</label>
					<input class="form-input-txt" type="text" name="proName" value="" />
				</div>
				<div class="form-group">
					<label for="">商品价格</label>
					<input class="form-input-txt" type="text" name="proPrice" value="" />
				</div>
				<div class="form-group">
					<label for="">商品描述</label>
					<textarea id="content" class="form-input-textara" type="text" name="proDesc"></textarea>
				</div>
				
				<div class="form-group">
					<label for="">剩余量</label>
					<input class="form-input-txt" type="text" name="proHassum" value="" />
				</div>
				<div class="form-group">
					<label for="">商品图片</label>
					
					<input class="" type="file" id="myfile" name="source" value="" />
					
				</div>
				
				<div id="large"></div>
				<div class="form-group" style="margin-left:150px;">
					 
				<input type="submit" class="sub-btn" id="btn" value="提  交" />
				<input type="reset" class="sub-btn" value="重  置" />
					
				</div>
			</form>
			</div>
			</div>
		</div>
	</div>
</body>


</html>